module SandBox 
  class StickyNote < DynamicWindow

    state_defined_by :note => 'Note to self...'

    def initialize
      super('Notes')
      self.style = 'width:100%;height:100%'
    end

    def render      
      add(DrunkenMaster::Form.new(
            :action => callback(:save),
            :style => 'width:100%;height:100%')
        ) do
        e :textarea, 
          :name => 'note',
          :innerHTML => note,
          :style => 'width:100%;height:100%;position:relative'
        e :input,
          :type => 'submit',
          :name => 'save',
          :style => 'position:absolute;top:0;right:0',
          :onclick => "Ext.get(this.form).getUpdater().formUpdate(this.form); return false"
      end      
      super()
    end
    
    def save
      self.note = context.request.params['note']
    end
    
  end
end